<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
 $id=isset($_GET["id"])?$_GET["id"]:"0";
        
if($id!="0"){
    $role=$T->db->query("select * from sys_role where id=".$id)->fetch(PDO::FETCH_ASSOC);
    $T->Set("rolename",$role["rolename"]);
    $T->Set("id",$role["id"]);
    $role_menu=$T->db->query("select * from sys_role_menu where rid=".$id)->fetch(PDO::FETCH_ASSOC);
    if($role_menu){
        $T->Set("menu_id",$role_menu["menu_id"]);
    }else{
        $T->Set("menu_id","");
    }
}
$s1="";
$s2="";
if(ckAdm()){
    $s1="select * from sys_menu where flag=0 and pid in (select id from sys_menu where pid=0 and flag=0) order by odx asc";
    $s2="select * from sys_menu where pid=? and flag=0 order by odx asc";
}else{
    $m_id="0";
    $s_rle=$T->db->query("select * from sys_role_menu where rid=".$_SESSION["role"])->fetch(PDO::FETCH_ASSOC);
    if($s_rle){
        $m_id=$s_rle["menu_id"];
    }
    $s1="select * from sys_menu where flag=0 and pid in (select id from sys_menu where pid=0 and flag=0) and id in (".$m_id.") order by odx asc";
    $s2="select * from sys_menu where pid=? and flag=0 and id in (".$m_id.") order by odx asc";
}
$T->SetBlock2("list",$s1,array(array("block"=>"rp","pid"=>"id","sql"=>$s2)));
        

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 